/*
 * Lenovo Group
 * Copyright (c) 2015-2016 All Rights Reserved.
 * 
 * Project Name:assign-tracer
 * Create Time: 2016年2月1日 下午12:25:56
 */
package com.lenovo.lmrp.server.assigntracer.repository;

import com.lenovo.lmrp.api.model.entity.CustomerPO;
import com.lenovo.lmrp.api.model.entity.ProjectPO;
import com.lenovo.sdc.framework.dao.ADaoFactory;
import com.lenovo.sdc.framework.dao.ICommonDAO;
import com.lenovo.sdc.framework.util.exception.ErrorCode;
import com.lenovo.sdc.framework.util.exception.TraceableException;

/**
 * @author zhangzhenga
 *
 */
public class BaseInfoRepository {

    /**
     * 查询项目实体
     * 
     * @param itsmcode
     * @param projectId
     * @return
     */
    public ProjectPO getProjectById(String itsmcode, String projectId) {
        try (ICommonDAO dao = ADaoFactory.getDefault().createDAO(itsmcode)) {
            return dao.get(ProjectPO.class, projectId);
        }
        catch (Exception exp) {
            throw new TraceableException(ErrorCode.DB_QUERY_FAILED, exp);
        }
    }

    /**
     * 查询客户实体
     * 
     * @param itsmcode
     * @param customerId
     * @return
     */
    public CustomerPO getCustomerById(String itsmcode, String customerId) {
        try (ICommonDAO dao = ADaoFactory.getDefault().createDAO(itsmcode)) {
            return dao.get(CustomerPO.class, customerId);
        }
        catch (Exception exp) {
            throw new TraceableException(ErrorCode.DB_QUERY_FAILED, exp);
        }
    }
}
